package com.pubinfo.passbook.common.model.ruler;

import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.pubinfo.passbook.common.entity.TPassbook;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;

import java.math.RoundingMode;

@Data
public class PassbookInformation extends TPassbook
{
    @ApiModelProperty("金额合计")
    private String totalAmounts;
    @ApiModelProperty("医疗统筹基金支付")
    private String fundPayAmount;
    @ApiModelProperty("个人账户-本年支付")
    private String currPayment;
    @ApiModelProperty("个人自费")
    private String selfpaymentCost;
    @ApiModelProperty("个人自理")
    private String selfpaymentCare;
    @ApiModelProperty("个人自付")
    private String selfpaymentAmount;

    public void setInformation() {
        String xml = this.getEinvoiceXml();
        Document document = null;
        try {
            document = DocumentHelper.parseText(xml);
        } catch (DocumentException e) {
        }
        Element root = document.getRootElement();
        PayInformation payInformation=new PayInformation(root);
        this.totalAmounts=payInformation.getTotalAmount().setScale(2, RoundingMode.HALF_UP).toString();
        this.fundPayAmount=payInformation.getFundPayAmount().setScale(2, RoundingMode.HALF_UP).toString();
        this.currPayment=payInformation.getIndividualAccountCurrPayment().setScale(2, RoundingMode.HALF_UP).toString();
        this.selfpaymentCost=payInformation.getSelfpaymentCost().setScale(2, RoundingMode.HALF_UP).toString();
        this.selfpaymentCare=payInformation.getSelfpaymentCare().setScale(2, RoundingMode.HALF_UP).toString();
        this.selfpaymentAmount=payInformation.getSelfpaymentAmount().setScale(2, RoundingMode.HALF_UP).toString();

    }
}
